<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Bai 3.2</title>
</head>

<body>
<?php
	if(isset($_POST['nam']))
	{
		function KiemTraNamNhuan($nam)
		{
			return ($nam%400==0|| ($nam%4==0 && $nam%100!=0));
		}
		$nam=	$_POST['nam'];
		if(is_numeric($nam))
		{
			if($nam>=2000)
			{
				$i=2000;
				do{
					$kq.=$i." ";
					$i+=4;
				}while($i<=$nam);
				$kq.="là năm nhuận";
			}
			elseif($nam<2000)
			{
				$i=2000;
				do{
					$kq.=$i." ";
					$i-=4;
				}while($i>=$nam);
				$kq.="là năm nhuận";
			}
		}
		else
			$kq="Mời nhập năm";
	}

?>
<form id="form1" name="form1" method="post" action="Bai3_2.php">
  <table width="500" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
      <td bgcolor="#000099" style="text-align: center; font-size: 24px; color: #FFF;">TÌM NĂM NHUẬN</td>
    </tr>
    <tr style="text-align: center">
      <td bgcolor="#99CCFF">Năm: 
      <input name="nam" type="text" id="nam" value="<?php echo $_POST['nam'];?>" /></td>
    </tr>
    <tr style="text-align: center">
      <td bgcolor="#99CCFF"><label style="background-color:#FFC"><?php echo $kq;?></label>&nbsp;</td>
    </tr>
    <tr style="text-align: center">
      <td bgcolor="#99CCFF"><input style="background-color:#09F; color:#F00; font-weight:bold" type="submit" name="submit" id="submit" value="Tìm năm nhuận" /></td>
    </tr>
  </table>
</form>
</body>
</html>